<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="ln"></div>
    <script src="./src/react.js"></script>
    <script src="./src/react-dom.js"></script>
    <script src="./src/babel.js"></script>
    <script type="text/babel">
        class Bti extends React.Component {
            constructor() {
                super()
                this.state = {
                    n: 1
                }
            }
            jia = () => {
                let n = this.state.n + 1
                this.setState({
                    n: n
                })
            }
            componentDidMount() {
                console.log('组件已挂载至视图 -- 执行一次');
            }
            componentDidUpdate() {
                console.log('组件已更新 -- state props 更新后即执行');
            }
            componentWillUnmount() {
                console.log('组件将要销毁 -- 执行一次');
            }
            render() {
                return (
                    <div>
                        头部组件{this.state.n}
                        <button onClick={this.jia}>点击</button>
                    </div>
                )
            }
        }

        ReactDOM.render(
            <Bti></Bti>,
            document.getElementById('ln')
        )
    </script>
</body>

</html>